//
//  ZZCStartView.m
//  B段项目
//
//  Created by dllo on 15/12/22.
//  Copyright © 2015年 张智超. All rights reserved.
//

#import "ZZCStartView.h"

#define ReWidth self.frame.size.height

@implementation ZZCStartView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

- (void)createSubView{
    
    self.backgroundColor = [UIColor whiteColor];
    //线
    self.lineView = [[UIView alloc]init];
    self.lineView.backgroundColor = [UIColor grayColor];
    [self addSubview:self.lineView];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.mas_left).offset(15);
        make.bottom.equalTo(self.mas_bottom).offset(-80);
        make.right.equalTo(self.mas_right).offset(-15);
        make.height.mas_equalTo(1);
    }];
    
    
    //四个page
    self.pageOne = [[UIView alloc]initWithFrame:CGRectMake(self.frame.size.width / 2 - 14 * 3.5, self.frame.size.height / 6 / 3, 14, 3)];
    self.pageOne.backgroundColor = [UIColor grayColor];
    [self addSubview:self.pageOne];
    
    
    self.pageTwo = [[UIView alloc]initWithFrame:CGRectMake(self.frame.size.width / 2 - 14 * 1.5, self.frame.size.height / 6 / 3, 14, 3)];
    self.pageTwo.backgroundColor = [UIColor colorWithRed:155 / 255.0 green:198/255.0 blue:121 / 255.0 alpha:1.0];
    [self addSubview:self.pageTwo];
    
    
    self.pageThree = [[UIView alloc]initWithFrame:CGRectMake(self.frame.size.width / 2 + 14 * 0.5, self.frame.size.height / 6 / 3, 14, 3)];
    self.pageThree.backgroundColor = [UIColor grayColor];
    [self addSubview:self.pageThree];
    
    
    self.pageFour = [[UIView alloc]initWithFrame:CGRectMake(self.frame.size.width / 2 + 14 * 2.5, self.frame.size.height / 6 / 3, 14, 3)];
    self.pageFour.backgroundColor = [UIColor grayColor];
    [self addSubview:self.pageFour];
    
    
    //播放按钮
    self.startButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.startButton.frame = CGRectMake(self.frame.size.width / 2 - self.frame.size.height / 5 * 2 / 2, self.frame.size.height / 5 * 2, self.frame.size.height / 5 * 2, self.frame.size.height / 5 * 2);
    //裁掉边框
    self.startButton.layer.masksToBounds = YES;
    //半径
    self.startButton.layer.cornerRadius = self.frame.size.height / 5 * 2 / 2;
    // 设置边框宽度
    self.startButton.layer.borderWidth = 2;
    // 设置边框颜色
    self.startButton.layer.borderColor = [UIColor colorWithRed:230 / 255.0 green:230 / 255.0 blue:230 / 255.0 alpha:1.0].CGColor;
    [self addSubview:self.startButton];
    
    
    //创建一个小ImageView加在button上(因为图太大)
    //frame起始坐标随便写,下面通过center改变
    
    
    
    if ([[[NSUserDefaults standardUserDefaults]objectForKey:@"play"] isEqualToString:@"0"]) {
        UIImageView *startImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.startButton.frame.size.width / 3 * 2 - 2, self.startButton.frame.size.height / 3 * 2 - 2)];
        startImage.backgroundColor = [UIColor whiteColor];
        startImage.center = CGPointMake(self.startButton.center.x + 1, self.startButton.center.y);
        startImage.image = [UIImage imageNamed:@"iconfont-bofang2.png"];
        [self addSubview:startImage];
    }else{
        UIImageView *startImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.startButton.frame.size.width / 3 * 2 - 2, self.startButton.frame.size.height / 3 * 2 - 2)];
        startImage.backgroundColor = [UIColor whiteColor];
        startImage.center = CGPointMake(self.startButton.center.x , self.startButton.center.y);
        startImage.image = [UIImage imageNamed:@"iconfont-zanting-2.png"];
        [self addSubview:startImage];
    }
    
    
    //上一曲按钮
    self.lastMusicButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.lastMusicButton.frame = CGRectMake(0, 0, self.startButton.frame.size.width / 3 * 2, self.startButton.frame.size.height / 3 * 2);
    self.lastMusicButton.center = CGPointMake(self.frame.size.width / 8, self.startButton.center.y);
    //裁掉边框
    self.lastMusicButton.layer.masksToBounds = YES;
    //半径
    self.lastMusicButton.layer.cornerRadius = self.startButton.frame.size.height / 3 * 2 / 2;
    // 设置边框宽度
    self.lastMusicButton.layer.borderWidth = 2;
    // 设置边框颜色
    self.lastMusicButton.layer.borderColor = [UIColor colorWithRed:230 / 255.0 green:230 / 255.0 blue:230 / 255.0 alpha:1.0].CGColor;
    [self addSubview:self.lastMusicButton];
    
    
    
    //同上,创建一个小点的ImageView
    UIImageView *lastImage = [[UIImageView alloc]initWithFrame:CGRectMake(self.lastMusicButton.center.x, self.lastMusicButton.center.y, self.lastMusicButton.frame.size.width / 5 * 2, self.lastMusicButton.frame.size.height / 5 * 2)];
    lastImage.center = CGPointMake(self.lastMusicButton.center.x , self.lastMusicButton.center.y);
    lastImage.image = [UIImage imageNamed:@"iconfont-bofangqishangyiqu.png"];
    [self addSubview:lastImage];
    
    
    //下一曲按钮
    self.nextMusicButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.nextMusicButton.frame = CGRectMake(0, 0, self.startButton.frame.size.width / 3 * 2, self.startButton.frame.size.height / 3 * 2);
    self.nextMusicButton.center = CGPointMake(self.frame.size.width / 8 * 7, self.startButton.center.y);
    //裁掉边框
    self.nextMusicButton.layer.masksToBounds = YES;
    //半径
    self.nextMusicButton.layer.cornerRadius = self.startButton.frame.size.height / 3 * 2 / 2;
    // 设置边框宽度
    self.nextMusicButton.layer.borderWidth = 2;
    // 设置边框颜色
    self.nextMusicButton.layer.borderColor = [UIColor colorWithRed:230 / 255.0 green:230 / 255.0 blue:230 / 255.0 alpha:1.0].CGColor;
    [self addSubview:self.nextMusicButton];
    
    
    //同上,创建一个小点的ImageView
    UIImageView *nextImage = [[UIImageView alloc]initWithFrame:CGRectMake(self.nextMusicButton.center.x, self.nextMusicButton.center.y, self.nextMusicButton.frame.size.width / 5 * 2 , self.nextMusicButton.frame.size.height / 5 * 2)];
    nextImage.center = CGPointMake(self.nextMusicButton.center.x + 1, self.nextMusicButton.center.y);
    nextImage.image = [UIImage imageNamed:@"iconfont-bofangqixiayiqu.png.png"];
    [self addSubview:nextImage];
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
